﻿using Abp.Application.Services.Dto;
using FwProject.Comm.ExcelUtil;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using X.PagedList;

namespace FwProject.PrePaymentInfo.Dto
{
    public class ReceivableStatementOutputDto
    {
        /// <summary>
        /// 期初应收款
        /// </summary>
        public decimal InitialReceivables { get; set; } = 0m;

        /// <summary>
        /// 期末增加应收款
        /// </summary>
        public decimal FinalAddReceivable { get; set; } = 0m;
        /// <summary>
        /// 期末收回应收款
        /// </summary>
        public decimal FinalTakeReceivable { get; set; } = 0m;
        /// <summary>
        /// 期末总优惠
        /// </summary>
        public decimal FinalTotalDiscount { get; set; } = 0m;
        /// <summary>
        /// 期末使用预收款
        /// </summary>
        public decimal FinalUsePrePayment { get; set; } = 0m;
        /// <summary>
        /// 期末应收款
        /// </summary>
        public decimal FinalReceivables { get; set; } = 0m;

        public IPagedList<ReceivableStatementDetailDto> ReceivableStatementDetail { get; set; }
    }

    [DisplayName(displayName: "应收对账单")]
    public class ReceivableStatementDetailDto:EntityDto<Guid>
    {
        /// <summary>
        /// 业务类型
        /// </summary>
        [DisplayName(displayName: "业务类型")]
        [ExcelDateMember]
        public BusinessType BusinessType { get; set; }

        /// <summary>
        /// 餐厅Id
        /// </summary>
        public Guid? RestaurantId { get; set; }

        /// <summary>
        /// 单据编号
        /// </summary>
        [DisplayName(displayName: "单据编号")]
        [ExcelDateMember]
        public string DocumentNumber { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        [DisplayName(displayName: "创建日期")]
        [ExcelDateMember]
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 增加应收
        /// </summary>
        [DisplayName(displayName: "增加应收")]
        [ExcelDateMember(IsSum = true)]
        public decimal AddReceivable { get; set; } = 0m;

        /// <summary>
        /// 收回应收
        /// </summary>
        [DisplayName(displayName: "收回应收")]
        [ExcelDateMember(IsSum = true)]
        public decimal TakeReceivable { get; set; } = 0m;

        /// <summary>
        /// 总优惠
        /// </summary>
        [DisplayName(displayName: "总优惠")]
        [ExcelDateMember(IsSum = true)]
        public decimal TotalDiscount { get; set; } = 0m;

        /// <summary>
        /// 使用预收款
        /// </summary>
        [DisplayName(displayName: "使用预收款")]
        [ExcelDateMember(IsSum = true)]
        public decimal UsePrePayment { get; set; } = 0m;

        /// <summary>
        /// 应收款
        /// </summary>
        [DisplayName(displayName: "应收款")]
        [ExcelDateMember(IsSum = true)]
        public decimal FinalReceivables { get { return AddReceivable - TakeReceivable - TotalDiscount - UsePrePayment; } }


        [DisplayName(displayName: "期末应收款")]
        [ExcelDateMember(IsSum = true)]
        public decimal InitialReceivables { get; set; }
    }


    public enum BusinessType
    {
        收据,
        收款单
    }
}
